﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DIS_WEB_Client.ViewModels.GroupViewModel>" %>
<div class="AdminPageText">
List Of Orders
</div>
<% using (Html.BeginForm("UpdateOrders", "Admin", FormMethod.Post, new { id = "MySubmitForm" })){ %>
<table class="Grid" cellpadding="0" cellspacing="0">
	<thead>
		<tr>
			<th>ID</th>
            <th>OrderDate</th>
			<th>IsVerified</th>
			<th>IsShipped</th>
            <th>IsPaid</th>
            <th></th>
            <th></th>
		<tr>
	</thead>
	<% for (int i=0; i<Model.OrdersModel.GetModel.LstObjModel.Count; i++){
		if (i % 2 != 0) {%>
		<tr class="Row" id="row-<%= Model.OrdersModel.GetModel.LstObjModel[i].ID %>">
		<% }
		else { %>
		<tr class="AlternatingRow" id="row-<%= Model.OrdersModel.GetModel.LstObjModel[i].ID %>">
		<% } %>
            <td><span style=""><%= Model.OrdersModel.GetModel.LstObjModel[i].ID %></span></td>
			<td><span style=""><%= Model.OrdersModel.GetModel.LstObjModel[i].OrderDate %></span></td>
        <% if (Model.OrdersModel.GetModel.LstObjModel[i].ID == Model.OrdersModel.EditModel.ID)
            { %>
			<td><span style=""><%= Html.CheckBox("IsVerified", Model.OrdersModel.GetModel.LstObjModel[i].IsVerified)%></span></td>
			<td><span style=""><%= Html.CheckBox("IsShipped", Model.OrdersModel.GetModel.LstObjModel[i].IsShipped)%></span></td>
            <td><span style=""><%= Html.CheckBox("IsPaid", Model.OrdersModel.GetModel.LstObjModel[i].IsPaid)%></span></td>
            <td>
				<a href="#" onclick="submitForm();">
					<span style="color: Blue; text-decoration: underline">Update</span>
				</a>
				&nbsp;
                <%= Html.Hidden("Orders_From", Model.OrdersModel.ReferKeys.From)%>
                <%= Html.Hidden("Orders_To", Model.OrdersModel.ReferKeys.To)%>
				<%= Html.Hidden("Orders_ID", Model.OrdersModel.GetModel.LstObjModel[i].ID)%>
                <a href="../../Admin/CancelEditingOrders?idorder=<%= Model.OrdersModel.GetModel.LstObjModel[i].ID %>&from=<%= Model.OrdersModel.ReferKeys.From.ToString() %>&to=<%= Model.OrdersModel.ReferKeys.To.ToString() %>">
					<span style="color: Blue; text-decoration: underline">Cancel</span>
				</a>
			</td>
         <% }
            else
            { %>
            <td><span style=""><%= Html.CheckBox("IsVerified2", Model.OrdersModel.GetModel.LstObjModel[i].IsVerified, new { disabled = "disabled" })%></span></td>
			<td><span style=""><%= Html.CheckBox("IsShipped2", Model.OrdersModel.GetModel.LstObjModel[i].IsShipped, new { disabled = "disabled" })%></span></td>
            <td><span style=""><%= Html.CheckBox("IsPaid2", Model.OrdersModel.GetModel.LstObjModel[i].IsPaid, new { disabled = "disabled" })%></span></td>
            <td>
				<a href="../../Admin/EditOrders?idorder=<%= Model.OrdersModel.GetModel.LstObjModel[i].ID %>&from=<%= Model.OrdersModel.ReferKeys.From.ToString() %>&to=<%= Model.OrdersModel.ReferKeys.To.ToString() %>">
					<span style="color: Blue; text-decoration: underline">Edit</span>
				</a>
			</td>
         <% } %>
            <td style="text-align: center">
                <a href="../../Admin/SelectOrderDetail?idorder=<%= Model.OrdersModel.GetModel.LstObjModel[i].ID %>&from=<%= Model.OrdersModel.ReferKeys.From.ToString() %>&to=<%= Model.OrdersModel.ReferKeys.To.ToString() %>">
					<span style="">Select</span>
				</a>
			</td>
		</tr>
	<% } %>  
</table>
<% if (Model.SelectedOrdersModel != null)
   { %>
   <%
       var total = 0.0;
       for (int i = 0; i < Model.OrderDetailModel.GetModel.LstObjModel.Count; i++)
       {
           total += (Model.OrderDetailModel.GetModel.LstObjModel[i].Quantity * Model.OrderDetailModel.GetModel.LstObjModel[i].Price);
       }
    %>
    <br /><br />
    <span style="font-size:18px; font-weight:bold;">Order <%= Model.SelectedOrdersModel.GetModel.LstObjModel[0].ID %></span>
    <br />
    <table class="AdminPageText">
        <tr>
        <td width="130" style="font-weight: bold;">Total:</td>
        <td style="font-weight: bold; color: Red">
            <%= Math.Round(total, 2) %> USD
        </td>
        </tr>
        <tr>
        <td width="130">IDCustomer:</td>
        <td>
            <%= Model.SelectedOrdersModel.GetModel.LstObjModel[0].ID %>
        </td>
        </tr>
        <tr>
        <td width="130">Customer:</td>
        <td>
            <%= Model.SelectedOrdersModel.GetModel.LstObjModel[0].Customer.Name %>
        </td>
        </tr>
        <tr>
        <td width="130">Phone:</td>
        <td>
            <%= Model.SelectedOrdersModel.GetModel.LstObjModel[0].Customer.Phone %>
        </td>
        </tr>
        <tr>
        <td width="130">Address:</td>
        <td>
            <%= Model.SelectedOrdersModel.GetModel.LstObjModel[0].Customer.Address %>
        </td>
        </tr>
        <tr>
        <td width="130">Email:</td>
        <td>
            <%= Model.SelectedOrdersModel.GetModel.LstObjModel[0].Customer.Email %>
        </td>
        </tr>
        <tr>
        <td width="130">OrderDate:</td>
        <td>
            <%= Model.SelectedOrdersModel.GetModel.LstObjModel[0].OrderDate %>
        </td>
        </tr>
        <tr>
        <td width="130">IsVerified:</td>
        <td>
            <%= Model.SelectedOrdersModel.GetModel.LstObjModel[0].IsVerified%>
        </td>
        </tr>
        <tr>
        <td width="130">IsShipped:</td>
        <td>
            <%= Model.SelectedOrdersModel.GetModel.LstObjModel[0].IsShipped%>
        </td>
        </tr>
        <tr>
        <td width="130">IsShipped:</td>
        <td>
            <%= Model.SelectedOrdersModel.GetModel.LstObjModel[0].IsPaid %>
        </td>
        </tr>
    </table>
    <br />
    <div class="AdminPageText">
    List Of Foods In Order
    </div>
    <table class="Grid" cellpadding="0" cellspacing="0">
	<thead>
		<tr>
			<th>No.</th>
            <th>Food</th>
            <th>Quantity</th>
			<th>Price</th>
		<tr>
	</thead>
	<% for (int i=0; i<Model.OrderDetailModel.GetModel.LstObjModel.Count; i++){
		if (i % 2 != 0) {%>
		<tr class="Row" id="Tr1">
		<% }
		else { %>
		<tr class="AlternatingRow" id="row-<%= Model.OrderDetailModel.GetModel.LstObjModel[i].ID %>">
		<% } %>
            <td><span style=""><%= (i + 1) %></span></td>
            <td><span style=""><%= Model.OrderDetailModel.GetModel.LstObjModel[i].Item.Name %></span></td>
			<td><span style=""><%= Model.OrderDetailModel.GetModel.LstObjModel[i].Quantity %></span></td>
			<td><span style=""><%= Model.OrderDetailModel.GetModel.LstObjModel[i].Price %> USD</span></td>
		</tr>
	<% } %>  
</table>
<% } %>
<% } %>